const getDatePickerOptions = (range = 31) => {
  let minDate = null;
  let maxDate = null;
  return {
      onPick(date) {
          if(!date.maxDate) {
              let timeRange = range * 24 * 60 * 60 * 1000;
              minDate = date.minDate.getTime() - timeRange;
              maxDate = date.minDate.getTime() + timeRange;
          }else{
              minDate = null;
              maxDate = null;
          }
      },
      disabledDate(date) {
          if(minDate && maxDate) {
              return date.getTime() < minDate || date.getTime() > maxDate;
          }
      }
  };
};
let dates = getDatePickerOptions(7)
console.log(dates);